




# 1、列表推导式
list1 = [i for i in range(10)]
list2 = [i for i in range(1, 10, 2)]
list3 = [i for i in range(10) if i % 2 == 1]
print(list1)
print(list2)
print(list3)

# 生成50件衣服
list4 = [f"衣服{i}" for i in range(50)]
print(list4)

# 将如下字母修改成大写
list5 = ["allen", "dicker", "bar"]
#3 遍历取出来的调用upper()方法转换成大写
list6 = [item.upper() for item in list5]
print(list6)

# 2、集合推导式
s = {i for i in range(10)}
print(s)

# 3、字典推导式
lst7 = ["赵本山", "成龙", "李嘉诚"]
dic = {i:lst7[i] for i in range(len(lst7))}  #i是元素下标，lst[i]是列表下标对应的value
print("字典推导式：", dic)